package com.thread.test04;

import java.util.Timer;
import java.util.TimerTask;

/**
 * @author bin
 * @date 2025 - 03 -07
 **/
public class MainTest {
    public static void main(String[] args) throws InterruptedException {
        Guard t1 = new Guard();
        t1.start();
        Timer timer = new Timer();
        TimerTask task = new TimerTask() {
            @Override
            public void run() {
                double pace = t1.getPace();
                System.out.println(pace);
                if(pace >= 100){
                    timer.cancel();
                }
            }
        };
        timer.schedule(task, 0, 500);
    }
}
